package cn.bdqn.service.impl;

import cn.bdqn.mapper.ChargeRecordsDao;
import cn.bdqn.model.ChargeRecords;
import cn.bdqn.service.ChargeRecordsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 收费记录表(ChargeRecords)表服务实现类
 *
 * @author makejava
 * @since 2021-03-19 22:55:01
 */
@Service("chargeRecordsService")
public class ChargeRecordsServiceImpl implements ChargeRecordsService {

    @Resource
    private ChargeRecordsDao chargeRecordsDao;


    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public ChargeRecords queryById(Long id) {
        return this.chargeRecordsDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<ChargeRecords> queryAllByLimit(int offset, int limit) {
        return this.chargeRecordsDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param chargeRecords 实例对象
     * @return 实例对象
     */
    @Override
    public ChargeRecords insert(ChargeRecords chargeRecords) {
        this.chargeRecordsDao.insert(chargeRecords);
        return chargeRecords;
    }

    /**
     * 修改数据
     *
     * @param chargeRecords 实例对象
     * @return 实例对象
     */
    @Override
    public ChargeRecords update(ChargeRecords chargeRecords) {
        this.chargeRecordsDao.update(chargeRecords);
        return this.queryById(chargeRecords.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.chargeRecordsDao.deleteById(id) > 0;
    }
}
